﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Net;
namespace UI_Layer.Pages
{
    /// <summary>
    /// Interaction logic for CashPay.xaml
    /// </summary>
    public partial class CashPay : Page
    {
        public CashPay()
        {
            InitializeComponent();
            AmountToPayLabel.Content = BookingDetailsCreate.getPayAmount + " RON";

            DispatcherTimer timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
            {
                this.CashPay_clock_label.Content = DateTime.Now.ToString("HH:mm:ss");
            }, this.Dispatcher); 

        }

        private int currentBalance = 0;
        private int totalBalance = 0;
        private int returnAmount = 0;
        private int cost = 0;       

        private void ButtonClick_SimulateCashPay(object sender, RoutedEventArgs e)
        {            
            int amountIncrease = 1;            

            totalBalance = currentBalance + amountIncrease;
            currentBalance = totalBalance;
            cost = BookingDetailsCreate.getPayAmount;
            returnAmount = totalBalance - cost;

            Balance_Label.Text = totalBalance.ToString() + " RON";        
        }
        private void ButtonClick_GoBack(object sender, RoutedEventArgs e)
        {
            NavigationService.GoBack();
        }
      
        private void Balance_Label_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (totalBalance == cost || totalBalance > cost)
            {
                Confirmation.createBooking();
                Confirmation confirmationpage = new Confirmation();                
                NavigationService navservice = NavigationService.GetNavigationService(this);
                navservice.Navigate(confirmationpage);
            }
            
        }
    }
}
